package com.tanhua.backstage.service;
import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.common.enums.ReasonsForFreezingEnum;
import com.tanhua.common.mapper.QuestionMapper;
import com.tanhua.dubbo.server.api.ManageFreezeApi;
import com.tanhua.dubbo.server.enums.AccountrState;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManageService {
    @Autowired
    private QuestionMapper questionMapper;

    @Reference(version = "1.0.0")
    private ManageFreezeApi manageFreezeApi;



    /**
     * 冻结账号
     *
     * @param userId            被操作的用户的id
     * @param freezingTime
     * @param freezingRange
     * @param reasonForFreezing
     * @param forzenRemarks
     * @return
     */
    public String manageFreeze(Integer userId, Integer freezingTime, Integer freezingRange, String reasonForFreezing, String forzenRemarks) {

        //远程调用manageFreezeApi中的方法，将填充好的表传递到服务器中
        Boolean result = manageFreezeApi.manageFreeze(  userId,  freezingTime,  freezingRange,  reasonForFreezing,  forzenRemarks , AccountrState.FREEZE);
        //得到返回值，进行判断，是否冻结成功
        if (result) {
            return "冻结成功";
        }
        return null;
    }

    /**
     * 用户解冻
     *
     * @param userId
     * @param reasonsForThawing
     * @return
     */

    public String manageUnfreeze(Integer userId, String reasonsForThawing) {


        //远程调用manageFreezeApi中的方法，将填充好的表传递到服务器中
        Boolean result = manageFreezeApi.manageUnfreeze( userId,reasonsForThawing,AccountrState.THAW);
           if (result) {
               return "解冻成功";
           }
        return null;
    }
}
